<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function addText(){
				//1.创建碎片
				let df = document.createDocumentFragment()
				for (var i = 0; i < 10; i++) {
					let div=document.createElement("div")
					div.innerHTML="文字节点"+i
					df.appendChild(div)  //将每次循环创建的div先加入到碎片中
				}
				document.querySelector(".con").appendChild(df) //直接追加碎片
				
			}
			function addImage(){
				//1.创建碎片
				let df = document.createDocumentFragment()
				for (var i = 0; i < 10; i++) {
					let img=document.createElement("img")
					img.setAttribute("src","../../src/ok.png")
					df.appendChild(img)  //将每次循环创建的div先加入到碎片中
				}
				document.querySelector(".con").appendChild(df)
			}
		</script>
	</head>
	<body>
		<button onclick="addText()">批量添加文本</button>
		<button onclick="addImage()">批量添加图片</button>
		<div class="con"></div>
	</body>
</html>
